clear all

import delimited "cohort2_public_0-48m_5.18.23.csv"

rename public_id id

rename q12surveyyear year
rename q12surveymonth month
rename q12weight_p person_weight
rename q12weight_pu poverty_weight

gen own_rent = q12a1
label define ownlabel 1 "Rent" 2 "Own" 3 "live with family, pay part rent" 4 "live with family, pay no rent" 5 "rent a room, not form family" 6 "live in apt/house owned by other" 7 "live in temporary housing" 8 "live on street or park" 9 "other arrangement"
label val own_rent ownlabel
replace own_rent = . if own_rent > 9
order own_rent, after(q12a1)
drop q12a1

gen homeowner = 0 if own_rent !=2
replace homeowner = 1 if own_rent ==2
lab define ownlab 0 "No" 1 "Yes"
lab val homeowner ownlab

gen renter=0 if own_rent !=1 | own_rent !=4 | own_rent !=5
replace renter=1 if own_rent ==1 | own_rent==4 | own_rent==5
lab define rentlab 0 "No" 1 "Yes"
lab val renter rentlab
order homeowner renter, after(own_rent)

gen gender = q12a3_gender
label define genderlabel 1 "male" 2 "female"
label val gender genderlabel
replace gender = . if gender==97
gen male =0 if gender !=1
replace male=1 if gender==1
gen female =0 if gender !=2
replace female =1 if gender ==2
drop q12a3_gender
order gender male female, after(renter)

rename q12a3_age_tc age
replace age = . if age ==999

rename q12a4 others_inhome1
replace others_inhome1 = . if others_inhome1 > 2
rename q12a4_rel1 others_relation1
replace others_relation1 =. if others_relation1==97
rename q12a4_age1_tc others_age1
replace others_age1=. if others_age1==977
rename q12a4_gender1 others_gender1
replace others_gender1 = . if others_gender1==97


rename q12a4_rel2 others_relation2
replace others_relation2 =. if others_relation2==97
rename q12a4_age2_tc others_age2
replace others_age2=. if others_age2==977
rename q12a4_gender2 others_gender2
replace others_gender2 = . if others_gender2==97

rename q12a4_rel3 others_relation3
replace others_relation3 =. if others_relation3==97
rename q12a4_age3_tc others_age3
replace others_age3=. if others_age3==977
rename q12a4_gender3 others_gender3
replace others_gender3 = . if others_gender3==97

rename q12a4_rel4 others_relation4
replace others_relation4 =. if others_relation4==97
rename q12a4_age4_tc others_age4
replace others_age4=. if others_age4==977
rename q12a4_gender4 others_gender4
replace others_gender4 = . if others_gender4==97

rename q12a8x_tc monthly_rent
rename q12a9a rent_controlled
rename q12a10x_tc monthly_mortgage

gen monthly_rent_mortgage = monthly_rent if monthly_rent !=.
replace monthly_rent_mortgage = monthly_mortgage if monthly_mortgage !=.
replace monthly_rent_mortgage = 0 if own_rent ==4

rename q12a11 bedrooms
rename q12b1 neighborhood_rating
replace neighborhood_rating =. if neighborhood_rating > 5
rename q12b2 nyc_rating
replace nyc_rating =. if nyc_rating > 5

rename q12c1 freefood
recode freefood (2=0) 
lab define foodlab 0 "No" 1 "Yes"
label val freefood foodlab
replace freefood =. if freefood > 2

rename q12c2 freefood_howoften
replace freefood_howoften =. if freefood_howoften > 5

rename q12c3 homeless_facility
recode homeless_facility (2=0)
lab define faclabel 0 "No" 1 "Yes"
lab val homeless_facility faclabel
drop if homeless_facility > 2

rename q12c4x homeless_facility_nights

/*
rename qc5_1 assist_jobtrain
rename qc5_2 assist_educ
rename qc5_3 assist_housing
rename qc5_4 assist_finances
rename qc5_5 assist_obtainingbenefits
rename qc5_6 assist_healthservices
rename qc5_7 assist_counseling
rename qc5_8 assist_childcare
rename qc5_9 assist_parenting
rename qc5_10 assist_legal
rename qc5_11 assist_mentoring
rename qc5_12 assist_else

rename q12c6 visit_communityorg_times
replace visit_communityorg_times =. if visit_communityorg_times > 6
*/

rename q12d1 generalhealth_rating
replace generalhealth_rating = . if generalhealth_rating > 5
recode generalhealth_rating (5=1) (4=2) (2=4) (1=5)
lab define healthlab 1 "Poor" 2 "Fair" 3 "Good" 4 "Very Good" 5 "Excellent"
label val generalhealth_rating healthlab

rename q12d1_sp spousehealth_rating
replace spousehealth_rating = . if spousehealth_rating > 5
recode spousehealth_rating (5=1) (4=2) (2=4) (1=5)
lab define shealthlab 1 "Poor" 2 "Fair" 3 "Good" 4 "Very Good" 5 "Excellent"
label val spousehealth_rating shealthlab

rename q12d2 disability_preventwork
recode disability_preventwork (2=0)
lab define dislab 0 "No" 1 "Yes"
label val disability_preventwork dislab
replace disability_preventwork = . if disability_preventwork > 2

rename q12d2 spouse_preventwork
recode spouse_preventwork (2=0)
lab define sdislab 0 "No" 1 "Yes"
label val spouse_preventwork sdislab
replace spouse_preventwork = . if spouse_preventwork > 2

rename q12d7_1 depressed_howoften
rename q12d7_2 nervous_howoften
rename q12d7_3 restless_howoften
rename q12d7_4 hopeless_howoften
rename q12d7_5 effort_howoften
rename q12d7_6 worthless_howoften
/*
rename qd3 depressed_2weeks
recode depressed_2weeks (2=0)
lab define deplab 0 "No" 1 "Yes"
label val depression deplab
replace depression=. if depression >2

rename qd4 stressed_anxious_1month
recode stressed_anxious_1month (2=0)
lab define stresslab 0 "No" 1 "Yes"
label val stress stresslab
replace stress=. if stress >2
*/

rename q4d5 money_worries_howoften
recode money_worries_howoften (4=1) (3=2) (2=3) (1=4)
lab define moneylab 1 "Never" 2 "Rarely" 3 "Sometimes" 4 "Often"
label val money_worries moneylab
replace money_worries =. if money_worries > 4

rename q12d6 life_rating_0_10
replace life_rating_0_10 =. if life_rating_0_10 > 10

rename q12f1 food_insufficient
replace food_insufficient = . if food_insufficient > 4

rename q12f2 food_runout_worry
recode food_runout_worry (1=3) (3=1)
lab define worrylabel 1 "Never" 2 "Sometimes" 3 "Often"
label val food_runout_worry worrylabel
replace food_runout_worry =. if food_runout_worry > 3

rename q12f3 food_ranout
recode food_ranout (1=3) (3=1)
lab define ranoutlabel 1 "Never" 2 "Sometimes" 3 "Often"
lab val food_ranout ranoutlabel
replace food_ranout =. if food_ranout > 3

rename q12f4 rent_hardship
recode rent_hardship (2=0) (3=0)
lab define renthlab 0 "No" 1 "Yes"
lab val rent_hardship renthlab
replace rent_hardship = . if rent_hardship > 3

rename q12f5 moved_finances
recode moved_finances (2=0)
lab define movlab 0 "No" 1 "Yes"
lab val moved_finances movlab
replace moved_finances =. if moved_finances > 2

rename q12f6 moved_temporary
recode moved_temporary (2=0)
lab def movetmplab 0 "No" 1 "Yes"
lab val moved_temporary movetmplab
replace moved_temporary =. if moved_temporary > 1

rename q12f7 energy_bill
recode energy_bill (2=0)
lab def enlab 0 "No" 1 "Yes"
lab val energy_bill enlab
replace energy_bill =. if energy_bill > 1

rename q12f8 disconnected
recode disconnected (2=0)
lab def discolab 0 "No" 1 "Yes"
lab val disconnected discolab
replace disconnected =. if disconnected >1

rename q12f9 skipped_healthcare
recode skipped_healthcare (2=0)
lab def skiplab 0 "No" 1 "Yes"
lab val skipped_healthcare skiplab
replace skipped_healthcare =. if skipped_healthcare > 1

rename q12f10 ranout_money
recode ranout_money (3=1) (1=3)
lab def ranlab 1 "Never" 2 "Sometimes" 3 "Often"
label val ranout_money ranlab
replace ranout_money =. if ranout_money > 3

/*
imp_q12hous1 = didn't pay full amount of rent/mortgage
imp_q12hous2 = moved w/ someone else because of finances
imp_q12hous3 = moved temporraily
imp_q12bill1 = energy bill
imp_q12bill2 = disconnected
imp_q12medic1 = couldn't go to doctor because of cost
imp_q12financ1 = how often run out of money
imp_q12food1 = food insufficient
imp_q12food2 = food runout worry
imp_q12food3 = food ranout
imp_q12bor = borough
imp_qsnapeyes = Foodstamps/SNAP last 12 mos
imp_qretyes = retirement income last 12 mos
imp_qdisyes = disability income last 12 mos
imp_welfyes = public/cash assistance or welfare last 12 mos
imp_quiyes = unemployment compensation last 12 most
imp_qregyes = regular $ assistance from someone outside the home
imp_qothyes = other income/benefits not mentioned
imp_q12health = general health rating
imp_q12foodindom = food hardship indicator (moderate) last 12 months
imp_q12houseindmod = housing hardship indicator (moderate) last 12 mos
imp_q12billindmod = bill/utility hardship indicator (moderate) last 12 mos
imp_q12financindmod = financial hardship indicator (moderate) last 12 mos
imp_q12foodindsev = food hardship indicator (severe) last 12 mos
imp_q12billindsev = billing hardshpi indicator (severe) last 12 mos
imp_q12medichard = medical hardship indicator last 24 months (?)
imp_q12financindsv = financial hardhspi indicator (severe) last 12 mos
severe_hardship = presence of a severe material hardhspi
*/

rename imp_q12hous1 imp_rent_hardship
recode imp_rent_hardship (2=0)
lab define imprenthlab 0 "No" 1 "Yes"
lab val imp_rent_hardship imprenthlab

rename imp_q12hous2 imp_moved_finances
recode imp_moved_finances (2=0)
lab define movfin 0 "No" 1 "Yes"
lab val imp_moved_finances movfin

rename imp_q12hous3 imp_moved_temporary
recode imp_moved_temporary (2=0)
lab define impmovtemplab 0 "No" 1 "Yes"
label val imp_moved_temporary impmovtemplab

rename imp_q12bill1 imp_energy_bill
recode imp_energy_bill (2=0)
label define impbilllab 0 "No" 1 "Yes"
label val imp_energy_bill impbilllab

rename imp_q12bill2 imp_disconnected
recode imp_disconnected (2=0)
label define impdisclab 0 "No" 1 "Yes"
label val imp_disconnected impdisclab

rename imp_q12medic1 imp_skipped_healthcare
recode imp_skipped_healthcare (2=0)
label define impskiplab 0 "No" 1 "Yes"
label val imp_skipped_healthcare impskiplab

rename imp_q12financ1 imp_ranout_money
recode imp_ranout_money (3=1) (1=3)
lab def impranlab 1 "Never" 2 "Sometimes" 3 "Often"
label val imp_ranout_money impranlab

rename imp_q12food1 imp_food_insufficient

rename imp_q12food2 imp_food_runout_worry
recode imp_food_runout_worry (1=3) (3=1)
lab define impworrylabel 1 "Never" 2 "Sometimes" 3 "Often"
label val imp_food_runout_worry impworrylabel

rename imp_q12food3 imp_food_ranout
recode imp_food_ranout (1=3) (3=1)
lab define impranoutlabel 1 "Never" 2 "Sometimes" 3 "Often"
lab val imp_food_ranout impranoutlabel

rename imp_qbor borough

rename imp_q12snapyes imp_snap_12mos
recode imp_snap_12mos (2=0)
lab define impsnaplab 0 "No" 1 "Yes"
lab val imp_snap_12mos impsnaplab

rename imp_q12retyes imp_retirement_12mos
recode imp_retirement_12mos (2=0)
lab define impretlab 0 "No" 1 "Yes"
lab val imp_retirement_12mos impretlab

rename imp_q12disyes imp_disability_12mos
recode imp_disability_12mos (2=0)
lab define impdislab 0 "No" 1 "Yes"
lab val imp_disability_12mos impdislab

rename imp_q12welfyes imp_welfare_12mos
recode imp_welfare_12mos (2=0)
lab define impwelflab 0 "No" 1 "Yes"
lab val imp_welfare_12mos impwelflab

rename imp_q12uiyes imp_unemployment_12mos
recode imp_unemployment_12mos (2=0)
lab define impumplab 0 "No" 1 "Yes"
lab val imp_unemployment_12mos impumplab

rename imp_q12regyes imp_regcashassist_12mos
recode imp_regcashassist_12mos (2=0)
lab define impregcashlab 0 "No" 1 "Yes"
lab val imp_regcashassist_12mos impregcashlab

rename imp_q12othyes imp_otherbenefits
recode imp_otherbenefits (2=0)
lab define impotherlab 0 "No" 1 "Yes"
lab val imp_otherbenefits impotherlab

*rename imp_q12health imp_genhealth_rating

rename imp_q12foodindmod foodhardship_moderate
recode foodhardship_moderate (2=0)
lab define modfoodhardship 0 "No" 1 "Yes"
lab val foodhardship_moderate modfoodhardship

rename imp_q12houseindmod househardship_moderate
recode househardship_moderate (2=0)
lab define hhhardshiplab 0 "No" 1 "Yes"
lab val househardship_moderate hhhardshiplab

rename imp_q12billindmod energyhardship_moderate
recode energyhardship_moderate (2=0)
lab define ehardshiplab 0 "No" 1 "Yes"
lab val energyhardship_moderate ehardshiplab

rename imp_q12financindmod financialhardship_moderate
recode financialhardship_moderate (2=0)
lab define finhardshiplab 0 "No" 1 "Yes"
lab val financialhardship_moderate finhardshiplab

rename imp_q12foodindsev foodhardship_severe
recode foodhardship_severe (2=0)
lab define foodhardsevlab 0 "No" 1 "Yes"
lab val foodhardship_severe foodhardsevlab

rename imp_q12houseindsev househardship_severe
recode househardship_severe (2=0)
lab define househardsevlab 0 "No" 1 "Yes"
label val househardship_severe househardsevlab

rename imp_q12billindsev energyhardship_severe
recode energyhardship_severe (2=0)
lab define ehardshipsevlab 0 "No" 1 "Yes"
lab val energyhardship_severe ehardshipsevlab

rename imp_q12medichard medicalhardship_24mos
recode medicalhardship_24mos (2=0)
lab define medhardshiplab 0 "No" 1 "Yes"
lab val medicalhardship_24mos medhardshiplab

rename imp_q12financindsev financialhardship_severe
recode financialhardship_severe (2=0)
lab define finhardseverelab 0 "No" 1 "Yes"
lab val financialhardship_severe finhardseverelab
*

/*
rename q12g0 workedforpay_lastweek
recode workedforpay_lastweek (2=0)
lab def workedpaylab 0 "No" 1 "Yes"
lab val workedforpay_lastweek workedpaylab
replace workedforpay_lastweek =. if workedforpay_lastweek > 2

rename q12g3 spouseworked_lastweek
recode spouseworked_lastweek (2=0)
lab def spouseworklab 0 "No" 1 "Yes"
lab val spouseworked_lastweek spouseworklab
replace spouseworked_lastweek = . if spouseworked_lastweek > 2
*/

rename q12h5_6 wic_12mos
recode wic_12mos (2=0)
lab def wiclab 0 "No" 1 "Yes"
lab val wic_12mos wiclab
replace wic_12mos = . if wic_12mos > 2

rename q12h5_7 houseassist_12mos
recode houseassist_12mos (2=0)
lab def houseaslab 0 "No" 1 "Yes"
lab val houseassist_12mos houseaslab
replace houseassist_12mos = . if houseassist_12mos > 2

rename q12h5_8 medicaid_12mos
recode medicaid_12mos (2=0)
lab def medlab 0 "No" 1 "Yes"
lab val medicaid_12mos medlab
replace medicaid_12mos = . if medicaid_12mos > 2

rename qi3 internet_access
rename qi4 inter_access_mobile

rename qchildx_tc children_under18
rename q12adultx_tc hh_adults
rename qpersonx_tc hh_size

rename imp_race race
gen white = 0 if race !=1
replace white = 1 if race==1
gen black = 0 if race !=2
replace black=1 if race==2
gen asian=0 if race !=3
replace asian=1 if race==3
gen race_other=0 if race !=4
replace race_other=1 if race==4
gen hispanic=0 if race !=5
replace hispanic=1 if race==5

rename imp_educat educ
rename imp_q12moswork months_worked
rename imp_q12smoswork spousemonths_worked

rename q12sevhard severe_hardship
recode severe_hardship (2=0)
lab def hardlab 0 "No" 1 "Yes"
lab val severe_hardship hardlab

rename q12frsl freelunch_amount
rename q12wicval wic_amount

rename imp_q12earnhd_tc earnings
rename imp_q12earnsp_tc spouse_earnings
rename imp_q12incret_tc retirement_earnings
rename imp_q12incdis_tc disability_income
rename imp_q12incwelf_tc welfare_income
rename imp_q12incui_tc unemployment_income
rename imp_q12incsnap_tc snap_income
rename q12fiitax_tc federal_taxes
rename q12siitax_tc state_taxes
rename q12fica_tc fica_taxes
rename q12spmpov spm_poverty_status
recode spm_poverty_status (2=0)
lab def spmlab 0 "No" 1 "Yes"
lab val spm_poverty_status spmlab
/*
rename q12b3 physicalhealth_rating
recode physicalhealth_rating (1=5) (2=4) (4=2) (5=1)
lab def physlab 1 "Poor" 2 "Fair" 3 "Good" 4 "Very Good" 5 "Excellent"
lab val physicalhealth_rating physlab
replace physicalhealth_rating = . if physicalhealth_rating > 5

rename q12b4 mentalhealth_rating
recode mentalhealth_rating (1=5) (2=4) (4=2) (5=1)
lab def mentlab 1 "Poor" 2 "Fair" 3 "Good" 4 "Very Good" 5 "Excellent"
lab val mentalhealth_rating mentlab
replace mentalhealth_rating = . if mentalhealth_rating > 5
*/
drop q*
gen wave=4

save wave4.dta, replace